home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-04-25 | 4.4 KB | 149 lines | [TEXT/MPS ] |
- ;
- ; File: DRVRGlue.a
- ;
- ; Contains: DRVR interface
- ; Version: xxx put version here xxx
- ;
-
- ;
- ; Copyright: 1998 by Apple Computer, Inc., all rights reserved.
- ;
- ; File Ownership:
- ;
- ; DRI: xxx put dri here xxx
- ;
- ; Other Contact: xxx put other contact here xxx
- ;
- ; Technology: xxx put technology here xxx
- ;
- ; Writers:
- ;
- ; (JRH) Rhoads Hollowell
- ; (DF) David Ferguson
- ;
- ; Change History (most recent first):
- ;
- ; <USB6> 10/20/99 JRH Fixed a benign redefinition warning which appeared when JL added
- ; dVMImmuneMask to Devices.i.
- ; <USB5> 6/7/99 DF convert interface to C, return proper results for immediate,
- ; sync & async cases.
- ; 27 Jul 98 oja VMImmuneMask not set so that we HoldMemory on io buffers, param blocks
- ; 24 Apr 98 oja DrvrDone takes an error, passes on to JIODone
- ; 26 Mar 98 oja changed driver name to ".USB--Print___"
- ; 28 Feb 98 oja loosely based on Apple's StyleWriter DRVR
- ;
- ; To Do:
- ;
-
-
- BLANKS ON
- STRING ASIS
-
- INCLUDE 'LowMem.a'
- INCLUDE 'Devices.a'
- ;
- ; for an explanation of VMimmune and gestalt see AsyncDriverSample 1.0b4
- ;
- dDriverGestaltEnableMask EQU $0004 ; See DriverGestalt.h
-
- drvrFlags EQU dReadEnableMask + dWritEnableMask + dCtlEnableMask + dStatEnableMask
- drvrSystemFlags EQU dNeedLockMask
-
- DRVREntry MAIN EXPORT
-
- IMPORT DRVROpen, DRVRPrime, DRVRControl, DRVRStatus, DRVRClose
-
- Header
- dc.w drvrFlags + drvrSystemFlags
- DC.W 0 ; no run time
- DC.W 0 ; no events
- DC.W 0 ; no menu
-
- ; Entry point offset table to the procs: Open, Prime, Control, Status, Close
- DC.W MyOpen - DRVREntry ; open routine
- DC.W MyPrime - DRVREntry ; prime
- DC.W MyControl - DRVREntry ; control
- DC.W MyStatus - DRVREntry ; status
- DC.W MyClose - DRVREntry ; close
-
- ; Title
- ; include three pad bytes so we can re-number the driver
- DC.B 14 ;Length byte
- DC.B '.USB--Print---' ;Pad to odd # of chars, so 1st routine
- ; will be word-aligned.
-
- ; Push the address of the routine we wish to call and jump to the glue
- ; which sets up the parameters and calls the actual driver implementation
- MyOpen PEA DRVROpen
- bra.s MyImmGlue
- MyPrime PEA DRVRPrime
- bra.s MyIOGlue
- MyControl PEA DRVRControl
- bra.s MyCtlGlue
- MyStatus PEA DRVRStatus
- bra.s MyIOGlue
- MyClose PEA DRVRClose
-
- ;
- ; This glue code is used for Open/Close - functions that only return immediate results
- ;
-
- MyImmGlue
- MOVEM.L A0-A1,-(A7) ; save params to the routine
- MOVE.L A1,-(A7) ; pass the device control entry
- MOVE.L A0,-(A7) ; pass the parameter block
- MOVEA.L $0010(A7),A0 ; address of routine to jump to (C calling conventions)
- JSR (A0) ; do it
- ADDQ #8,SP ; clean up stack
- MOVEM.L (A7)+,A0-A1 ; restore device parameters
- ADDQ #4,SP ; removed function address
- BRA.S ImmedRTS ; just return
-
- MyCtlGlue
- MOVEM.L A0/A1,-(A7) ; save params to the routine
- MOVE.L A1,-(A7) ; pass the device control entry
- MOVE.L A0,-(A7) ; pass the parameter block
- MOVEA.L $0010(A7),A0 ; address of routine to jump to (C calling conventions)
- JSR (A0) ; do it
- ADDQ #8,SP ; clean up stack
- MOVEM.L (A7)+,A0/A1 ; restore device parameters
- ADDQ #4,SP ; removed function address
- CMPI.W #killCode,CntrlParam.csCode(A0)
- BNE.B IOReturn ; killIO always returns immediately
- BRA.S ImmedRTS
-
- MyIOGlue
- MOVEM.L A0/A1,-(A7) ; save params to the routine
- MOVE.L A1,-(A7) ; pass the device control entry
- MOVE.L A0,-(A7) ; pass the parameter block
- MOVEA.L $0010(A7),A0 ; address of routine to jump to (C calling conventions)
- JSR (A0) ; do it
- ADDQ #8,SP ; clean up stack
- MOVEM.L (A7)+,A0/A1 ; restore device parameters
- ADDQ #4,SP ; removed function address
-
- IOReturn
- MOVE.W IOParam.ioTrap(A0), D1
- BTST #noQueueBit,D1 ; test for an async call
- BEQ.S Queued ; if not async, we're done
-
- TST.W D0 ; test async return result
- BLE.B ImmedRTS ; if error or noErr we should return immediately
- CLR.W D0 ; in progress gets converted to noErr
- ImmedRTS
- MOVE.W D0,IOParam.ioResult(a0) ; return the immediate result
- RTS
-
- Queued
- TST.W D0 ; test async return result
- BLE.B IODone ; if io is complete then we should return through the jIODone vector
- CLR.W D0 ; in progress gets converted to noErr
- RTS
- IODone
- SUBQ.W #4,A7 ; else get the JIODone vector
- _LMGetJIODone ; so we can jump to it.
- RTS
-
- ENDPROC
- END
-